﻿using BackData;
using Domain.RBAC;
using Infratructure;
using MediatR;
using Team.API.Applocation.Command.Quality;

namespace Team.API.Applocation.Hanldler.Quality
{
    public class GetUserHandler : IRequestHandler<GetUserCommand, APIResult<List<Usermodel>>>   
    {
        private readonly IRepository<Usermodel> userRep;

        public GetUserHandler(IRepository<Usermodel> userRep)
        {
            this.userRep = userRep;
        }
        public async Task<APIResult<List<Usermodel>>> Handle(GetUserCommand request, CancellationToken cancellationToken)
        {
            var list = userRep.GetAll().Where(x => !x.IsDel);
            return new APIResult<List<Usermodel>>
            {
                Code = StateCode.OK,
                Result = list.ToList(),
                Message = "获取用户成功"
            };
        }
    }
}
